package model

import "time"

type AdminUser struct {
	Model
	Username  string
	Password  string
	RoleId    int
	Ip        string
	LoginTime time.Time `gorm:"default:''"`
	Status    uint
}

func (table *AdminUser) TableName() string {
	return "t_admin_user"
}

type AdminUserPage struct {
	Data      []AdminUser `json:"data"`
	TotalRows int64       `json:"total_rows"`
}

//获取role_id
func (table *AdminUser) GetRole(id uint) int {
	var admin AdminUser
	result := UseCon().Where("id=?", id).First(&admin)
	if result.Error != nil || result.RowsAffected == 0 {
		return 0
	}
	return admin.RoleId
}
